package net.cyndeline.rldungeon.dgs.strategy.pointlessArea.help

import scala.reflect.runtime.universe._

/**
 * A mutable container for immutable graph nodes, that can be owned by multiple collections without the need to
 * update them all when a node changes.
 */
class NodeStorage[NodeType](n: NodeType) {
  private var nde: NodeType = n

  def node: NodeType = nde
  def node_=(newNode: NodeType) = { nde = newNode }

  override def toString: String = "NStorage<" + n.toString + ">"
}

trait StorageFactory {
  def store[T](n: T): NodeStorage[T]
}

class NodeStorageFactory extends StorageFactory {
  def store[T](n: T): NodeStorage[T] = new NodeStorage(n)
}
